#ifndef STONE_H
#define STONE_H

#include<QString>
class Stone
{
public:
    Stone();

    enum TYPE{JIANG,SHUAI,SHI1,SHI2,XIANG1,XIANG2,CHE1,CHE2,PAO1,PAO2,MA,BING,ZU};

    int _row;
    int _col;
    int _id;
    bool _dead;
    bool _red;
    TYPE _type;

    void init(int id){
        struct{
            int row,col;
            Stone::TYPE type;
        }
        //初始化
        position[32]={
            {0,0,Stone::CHE1},
            {0,1,Stone::MA},
            {0,2,Stone::XIANG1},
            {0,3,Stone::SHI1},
            {0,4,Stone::SHUAI},
            {0,5,Stone::SHI1},
            {0,6,Stone::XIANG1},
            {0,7,Stone::MA},
            {0,8,Stone::CHE1},
            {2,1,Stone::PAO1},
            {2,7,Stone::PAO1},
            {3,0,Stone::BING},
            {3,2,Stone::BING},
            {3,4,Stone::BING},
            {3,6,Stone::BING},
            {3,8,Stone::BING},
            {6,0,Stone::ZU},
            {6,2,Stone::ZU},
            {6,4,Stone::ZU},
            {6,6,Stone::ZU},
            {6,8,Stone::ZU},
            {7,1,Stone::PAO2},
            {7,7,Stone::PAO2},
            {9,0,Stone::CHE2},
            {9,1,Stone::MA},
            {9,2,Stone::XIANG2},
            {9,3,Stone::SHI2},
            {9,4,Stone::JIANG},
            {9,5,Stone::SHI2},
            {9,6,Stone::XIANG2},
            {9,7,Stone::MA},
            {9,8,Stone::CHE2},
                     };

        _id=id;
        _dead=false;
        _red=id<16;

        if(id<32){
            _row=position[id].row;
            _col=position[id].col;
            _type=position[id].type;
        }
    }

    QString getText(){
        switch(this->_type){
        case CHE1:
            return "車";
        case MA:
            return "馬";
        case PAO1:
            return "炮";
        case BING:
            return "兵";
        case SHI1:
            return "仕";
        case XIANG1:
            return "相";
        case JIANG:
            return "将";
        case SHUAI:
            return "帥";
        case ZU:
            return "卒";
        case SHI2:
            return "士";
        case XIANG2:
            return "象";
        case PAO2:
            return "砲";
        case CHE2:
            return "車";
        }
        return "啦啦啦";
    }

};

#endif // STONE_H
